<template>
  <div class="layout">
    <div class="title">{{ title }}</div>

    <template v-if="dataShow">
      <div>
        <a-date-picker v-model:value="dataValue" :format="YYYY / MM / DD" />
      </div>
    </template>

    <div class="hide" v-if="hideShow">
      <a-switch v-model:checked="checked" size="small" @click="clickCom()" /> 隐藏已完成事项
    </div>
  </div>
</template>

<script>
import { toRefs, defineComponent,ref } from "vue";
export default defineComponent({
  props: {
    title: String,
    dataShow: Boolean,
    hideShow: Boolean,
  },
  emit:['clickCom'],
  setup(props,ctx) {
    const { title, dataShow } = toRefs(props);
    const checked = ref(false)

    // 选择只显示任务
    const clickCom = () => {
      let data = checked.value

      // 传给父组件
      ctx.emit('clickCom',data)
    }

    const focus = () => {
      console.log("focus");
    };
    const handleChange = (value) => {
      console.log(`selected ${value}`);
    };

    return {
      title,
      dataShow,
      focus,
      handleChange,
      checked,
      clickCom
    };
  },
});
</script>

<style lang="less" scoped>
.layout {
  height: 100px;
  line-height: 100px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding: 0 20px;
  .title {
    font-size: 24px;
  }
  .hide {
    font-size: 14px;
  }
}
</style>